<template>
  <div class="main">
    <div class="head flex">
      <div class="left">
        <h1 class="font-28">分销计划</h1>
        <p class="font-16">创建分销计划，发送分销链接给红人。</p>
      </div>
      <img src="@/assets/bg-task-right.png" class="right">
    </div>

    <div class="wrap">
      <div class="search flex flex-wrap flex-align-items-center">
        <div class="search-item flex flex-align-items-center">
          <p class="search-item-label font-14">计划名称：</p>
          <el-input v-model="searchForm.name"></el-input>
        </div>
        <div class="search-item flex flex-align-items-center">
          <p class="search-item-label font-14">商品：</p>
          <el-select v-model="searchForm.proId">
            <el-option v-for="item in proList" :key="item.id" :label="item.name" :value="item.id"></el-option>
          </el-select>
        </div>
        <div class="search-btns flex">
          <p class="font-14 pointer" @click="searchConfirm">查询</p>
          <p class="font-14 pointer" @click="reset">重置</p>
        </div>
      </div>
      <div class="btns flex">
        <p class="font-14 pointer">创建分销计划</p>
      </div>
      <el-table :data="tableData" style="width: 100%;" class="table">
        <el-table-column prop="value" label="关联时间" width="120" />
        <el-table-column prop="value" label="独立站平台" width="100" />
        <el-table-column prop="value" label="ID" width="120" />
        <el-table-column prop="value" label="店铺名称" width="110" />
        <el-table-column prop="value" label="域名" width="170" />
        <el-table-column prop="value" label="关联状态" width="100" />
        <el-table-column prop="value" label="同步时间" />
        <el-table-column label="操作" fixed="right" width="124">
          <template #default="scope">
            <div class="row-btns flex flex-align-items-center">
              <p class="row-btn font-14 pointer" @click="toDetail(scope.row)">详情</p>
              <span class="line"></span>
              <p class="row-btn font-14 pointer" @click="toEdit(scope.row)">编辑</p>
            </div>
          </template>
        </el-table-column>
      </el-table>
      <div class="pagination flex flex-align-items-center">
        <el-pagination layout="prev, pager, next, total" :total="form.total" />
      </div>
    </div>
  </div>
</template>

<script setup>
import { ref, onMounted } from 'vue';
import api from '@/api/index.js';

const proList = ref([
  {
    id: 1,
    name: 'xxxx'
  }
]);
const searchForm = ref({});
const form = ref({
  page: 1,
  perPage: 10,
  total: 1
});
const tableData = ref([]);

const searchConfirm = () => {
  form.value = {
    page: 1,
    perPage: form.value.perPage,
    ...searchForm.value
  }
}
const reset = () => {
  form.value = {
    page: 1,
    perPage: form.value.perPage,
    time: []
  };
  searchForm.value = {};
}
</script>

<style lang="less" scoped>
.main {
  padding: 16px;
}

.head {
  height: 150px;
  padding: 24px;
  background-image: url(@/assets/bg-task.png);
  background-repeat: no-repeat;
  background-size: cover;
  border-radius: 2px;
  margin-bottom: 24px;
  position: relative;

  .left {
    width: 40%;

    h1 {
      color: rgba(51, 51, 51, .85);
      margin-bottom: 12px;
      line-height: 40px;
    }

    p {
      color: hsla(0, 0%, 40%, .85);
      line-height: 22px;
    }
  }

  .right {
    position: absolute;
    right: 0;
    top: 0;
    z-index: 10;
    height: 100%;
  }
}

.wrap {
  padding: 16px;
  background: #fff;
  border-radius: 2px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .04), 0 2px 8px rgba(0, 0, 0, .04);

  .search {
    padding-bottom: 16px;
    margin-bottom: 16px;
    border-bottom: 1px solid #f2f3f5;

    .search-item {
      margin-right: 32px;

      .search-item-label {
        color: #333;
        width: 80px;
      }

      &::v-deep {
        .el-date-editor {
          width: 282px;
          flex-grow: 0;
        }

        .el-input {
          width: 282px;
        }
      }
    }

    .search-btns {
      p {
        width: 70px;
        padding: 0 8px;
        height: 32px;
        border-radius: 2px;
        text-align: center;

        &:first-child {
          background: @main-color !important;
          color: #fff;
          margin-right: 24px;
          line-height: 32px;
        }

        &:last-child {
          background: #fff;
          border: 1px solid #d9d9d9;
          color: #333;
          line-height: 30px;
        }
      }
    }
  }

  .btns {
    margin-bottom: 16px;

    p {
      min-width: 70px;
      padding: 0 8px;
      height: 32px;
      border-radius: 2px;
      background: @main-color !important;
      color: #fff;
      line-height: 32px;
    }
  }

  .table {
    &::v-deep {
      .el-table__empty-block {
        height: 500px !important;
      }
    }
  }

  .pagination {
    justify-content: end;
    margin-top: 16px;
  }
}
</style>
